
#if !defined RECONNECT_CONNECTION_H 
#define RECONNECT_CONNECTION_H

#include "RtCnPacketConnection.h"

/*class CBlockBack
{
protected:
	TBuff m_RcvBak;
	PACKET_TYPE m_PDUTypeBak;
	DWORD m_dwLatestPacketSizeBak;
	
	void Backup(TBuff &rBuff
		, PACKET_TYPE &type
		, DWORD &dwLatestPacketSize);
	void Restore(TBuff &rBuff
		, PACKET_TYPE &type
		, DWORD &dwLatestPacketSize);
	CBlockBack();
	~CBlockBack();
};*/
//////////////////////////////////////////////////////////////////////////


class CReconnClient:public CPacketClient//, public CBlockBack
{
public:
	CReconnClient(IConnectorT *pConnector);
	virtual ~CReconnClient();
	virtual void OnDisconnect(RtResult aReason,	IRtTransport *pTransport);
	virtual void OnConnectIndication(RtResult aReason, IRtTransport *aTrpt,IRtAcceptorConnectorId *aRequestId);
	RtResult SetOption(DWORD aCommand, LPVOID aArg);
	RtResult GetOption(DWORD aCommand, LPVOID aArg);
	
protected:
	void Reconnect();
	void OnTimer(CRtTimerWrapper *aId);
	virtual void OnReceiveConnectResponse(CRespPDU &responsePDU);
	
protected:
	CRtTimerWrapper		m_ReconnectTimer;
	ticker					m_ReconnectTick;
	LONG					m_ReconnectInterval;
};

class CReconnServer:public CPacketServer//, public CBlockBack
{
public:
	CReconnServer(IRtTransport *pTransport
		, ConnectionList_T *pConnectionList
		, IRtTransportSink* pITransportSink);
	virtual ~CReconnServer();

	virtual void OnDisconnect(RtResult aReason,	IRtTransport *pTransport);
	RtResult Disconnect(RtResult aReason = 0);

protected:
	void OnTimer(CRtTimerWrapper *aID);

protected:
	ConnectionList_T	*m_pConnectionList;
};

#endif
